package com.example.demo.dao;

import com.example.demo.domain.Stu;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface StuDAOByMybatis extends StuDao {
  @Select("select * from stu where id=#{id}")
  public Stu findById(@Param("id") long id);
  @Select("select * from stu")
  public List<Stu> findAll();
  @Insert("insert into stu (username,pass,java,math,os) values(#{stu.username},#{stu.pass},#{stu.java}," +
    "#{stu.math},#{stu.os})")
  @Options(useGeneratedKeys = true,keyProperty = "stu.id")
  int add(@Param("stu") Stu stu);
  @Delete("delete from stu where id=#{id}")
  public Stu DeleteById(@Param("id") long id);
}